package com.yunhe.abnormal.client.fallback;

import com.yunhe.abnormal.client.MeasRealtimeClient;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.Measurement;
import com.yunhe.common.model.data.MeasurementReqDTO;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author liuronglei
 */
@Component
public class MeasRealtimeFallbackFactory implements FallbackFactory<MeasRealtimeClient> {
    @Override
    public MeasRealtimeClient create(Throwable arg0) {
        return new MeasRealtimeClient() {
            
            @Override
            public ResponseEntity<ResultObject<Map<Long, Double>>> getMeasureRealtime(List<Long> pointNumber) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Map<Long, Double>>> getMeasureRealtime(MeasurementReqDTO reqDTO) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> setMeasureRealtime(Long pointNumber, Double value) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> saveMeasureRealtime(DomainList<Measurement> list) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
